﻿@model IEnumerable<Enter.Mvc.Mall.Model.Product.CategoryListModel>
@{
    ViewBag.Title = "sell";
    Layout = "~/Views/Shared/_MemberCenterLayout.cshtml";
}
<script>
    function GetCate(obj) {
        var str = obj.id.split('-');
        if (parseInt(str[0]) == 1) {
            $("#J_OlCascadingList li li").removeClass("cc-selected");
        }
         $(obj).addClass("cc-selected").siblings("li").removeClass("cc-selected");
        var index = parseInt(str[0]) + 1;

        var jqxhr = $.post("/Auction/GetCategory", { CateNO: str[4] }, function (data) {

            var dataList = data.list;
            var arr = "";

            if (dataList != null && dataList.length > 0) {

                var lis = "";
                for (var i = 0; i < dataList.length; i++) {
                    var cate = dataList[i];
                    if (dataList[0].IsParent) {
                        lis += '<li class="cc-cbox-item cc-hasChild-item" id="' + index + '-cc-cbox-item-' + cate.CNO + '" onclick="GetCate(this)" role="option">' + cate.CName + '</li>';
                    }
                    else {
                        lis += '<li class="cc-cbox-item" id="' + index + '-cc-cbox-item-' + cate.CNO + '" onclick="GetBrank(this)" role="option">' + cate.CName + '</li>';
                    }
                }



                arr += '<li tabindex="-1" class="cc-list-item">';
                arr += ' <div aria-activedescendant="cc-cbox-item5" class="cc-cbox" role="combobox">';
                arr += '  <div class="cc-cbox-filter">';
                arr += '    <label for="cc-cbox-filter357">输入名称/拼音首字母</label>';
                arr += '   <input style="width: 192px;" id="cc-cbox-filter' + index + '" autocomplete="off" role="textbox">';
                arr += ' </div>';
                arr += ' <ul class="cc-cbox-cont" id="' + index + '-ul-cbox-item" role="listbox">';



                arr += lis;

                arr += '</ul></div></li>';

            }
            var num = $("li.cc-list-item").length;
            if (parseInt(str[0]) < num) {  
                for (var i = parseInt(str[0]); i < num; i++) {
                    $($("li.cc-list-item")[parseInt(str[0])]).remove();
                }
            }
            getSelet();
            $("#J_OlCascadingList").append(arr);

        }, "json");


    }
    function GetBrank(obj) {
        var str = obj.id.split('-');
        $(obj).addClass("cc-selected").siblings("li").removeClass("cc-selected");
        var CateNo = str[4];
        var index = parseInt(str[0]) + 1;
        $("#CateNo").val(CateNo);
        $.post("/Auction/GetBrand", { CateNO: CateNo }, function (data) {
            var dataList = data.list;
            var arr = "";

            if (dataList != null && dataList.length > 0) {
                var lis = "";
                for (var i = 0; i < dataList.length; i++) {
                    var brand = dataList[i];
                    lis += '<li class="cc-cbox-item" id="' + index + '-cc-cbox-item-' + brand.BNO + '" onclick="GetBrankNO(this)" role="option">' + brand.BName + '</li>';

                }
                arr += '<li tabindex="-1" class="cc-list-item">';
                arr += ' <div aria-activedescendant="cc-cbox-item5" class="cc-cbox" role="combobox">';
                arr += '  <div class="cc-cbox-filter">';
                arr += '    <label for="cc-cbox-filter357">输入名称/拼音首字母</label>';
                arr += '   <input style="width: 192px;" id="cc-cbox-filter' + index + '" autocomplete="off" role="textbox">';
                arr += ' </div>';
                arr += ' <ul class="cc-cbox-cont" id="' + index + '-ul-cbox-item" role="listbox">';



                arr += lis;

                arr += '</ul></div></li>';
            }
            getSelet();
            $("#J_OlCascadingList").append(arr);
         
        }, "json");
    }
    function GetBrankNO(obj) {
        var str = obj.id.split('-');
        var BrandNo = str[4];
        $("#BrandNo").val(BrandNo);
    }
    function getSelet() {
        var selets = $("#J_OlCascadingList li.cc-selected");
        var selhtml = "";
        for (var i = 0; i < selets.length; i++) {
            if (i == 0) {
                selhtml += "<li>" + $($(selets)[i]).text() + "</li>"
            } else {
                selhtml += "<li>&nbsp;>&nbsp;" + $($(selets)[i]).text() + "</li>" 
            }
            
        }
        $("#J_OlCatePath").html(selhtml);
    }
</script>
<div class="main pageWidth pb">
    <div class="lastused-category  ">
        <label for="J_CateLastUsed">
            您最近使用的类目：</label>
        <select>
            <option>暂无</option>
        </select>
    </div>
    <div class="cate-container">
        <div id="cate-cascading">
            <a style="visibility: hidden;" href="#" class="cc-prev cc-nav" title="上一级" id="J_LinkPrev">
                <span>上一级</span></a>
            <div class="cc-listwrap">
                <ol id="J_OlCascadingList" class="cc-list">
                    <li tabindex="-1" class="cc-list-item">
                        <ul aria-activedescendant="cc-tree-item2" class="cc-tree" unselectable="on" hidefocus="-1"
                            tabindex="0" role="tree">
                            @foreach (var item in Model)
                            { 
                
            
                                <li aria-expanded="true" class="cc-tree-group cc-tree-expanded" role="treeitem">
                                    <div class="cc-tree-gname" id="cc-tree-gname1">@item.Category.CName</div>
                                    @if (item.ChildCategorys != null)
                                    { 
                                        <ul style="" class="cc-tree-gcont" role="group">
                                            @foreach (var cate in item.ChildCategorys)
                                            {
                                                <li class="cc-tree-item cc-hasChild-item" onclick="GetCate(this)" id="1-cc-tree-item-@cate.CNO" role="treeitem">@cate.CName</li>
                                            }
                                        </ul>
                                    }
                                </li>
                            }
                        </ul>
                    </li>
                  
                </ol>
            </div>
            <a style="visibility: hidden;" href="#" class="cc-next cc-nav" title="下一级" id="J_LinkNext">
                <span>下一级</span></a>
        </div>
    </div>
    <div class="cate-path">
        <dl>
            <div class="clearfix">
                <dt>您当前选择的是：</dt>
                <dd>
                    <ol class="category-path" id="J_OlCatePath">
                        <li>无</li>
                        <li>&nbsp;&gt;&nbsp;QQ游戏币/欢乐豆</li>
                        <li>&nbsp;&gt;&nbsp;1万</li>
                        <li>&nbsp;&gt;&nbsp;QQ游戏币</li>
                    </ol>
                    <div title="" style="display: none;" id="J_EmCateDesc" class="cate-desc">
                    </div>
                </dd>
            </div>
        </dl>
        <span id="J_SpanPointer" class="arrow up"></span>
    </div>
    <form id="J_FrmCateFilter" method="post" action="/auction/publish" name="mainform">
    <fieldset>
        <div class="cateBottom">
            <span class="cateBtn catePublish">
                <button type="submit" id="J_CatePubBtn">
                    我已阅读以下规则，现在发布宝贝</button>
            </span><span class="" id="J_PubLinkWrap"><a href="http://upload.taobao.com/auction/spu/search_spu.htm?auction_type=b&amp;auction_id=null&amp;itemNumId=15942451302&amp;wirelessOption=null&amp;wirelessmpChoosed=null&amp;isEdit=false"
                id="J_CatePubLink">利用宝贝模版发布</a> <span id="J_OperateBook" class="hidden"><a href="http://upload.taobao.com/auction/spu/search_spu.htm?auction_type=b&amp;auction_id=null&amp;itemNumId=15942451302">
                    搜索产品</a>，或 <a href="http://upload.taobao.com/auction/spu/add_spu.htm">上传新产品</a>
                </span></span>
            <input id="CateNo" name="CateNO" type="hidden" />
            <input id="BrandNo" name="BrandNo" type="hidden" />
        </div>
    </fieldset>
    </form>
</div>
